package com.app.manage.config;



import cn.dev33.satoken.exception.NotLoginException;
import com.app.manage.utils.Rsp;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.exceptions.TemplateInputException;


/**
 * springboot全巨额统一异常处理
 *
 * @author monxz
 *
 */
@ControllerAdvice
public class BaseControllerException {

    /**
     * 全局异常捕捉处理
     *
     * @param ex
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public Rsp errorHandler(Exception ex) {
        ex.printStackTrace();
        if(ex instanceof NotLoginException){
            return Rsp.fail("当前用户位登录!");
        }
        return Rsp.fail("系统异常，请联系管理员");
    }



}

